package MapAndSet.Map;
import java.util.*;

public class CountWords {
    public static void main(String[] args) {
        String[] sentence = {"world","man","man","woman","child"};
        func(sentence);
    }
    public static void func(String[] words) {
        Map<String,Integer> map = new HashMap<>();
        for(String word:words) {
            if(map.get(word)==null) {
                map.put(word,1);
            }else {
                int val = map.get(word);
                map.put(word,val+1);
            }
        }
        System.out.println(map);
    }
}
